package com.tools.mytools.encrypt;

public class MyKey {
	private static final String KEY1 = "TREND#!";
	private static final String KEY2 = "MICRO$1";

	private static String sKey = null;

	public static String getKey() {
		if (sKey == null) {
			sKey = generateKey();
		}

		return sKey;
	}

	public static String generateKey() {
		byte[] key1Bytes = KEY1.getBytes();
		byte[] key2Bytes = KEY2.getBytes();

		int length = key1Bytes.length < key2Bytes.length ? key1Bytes.length
				: key2Bytes.length;
		byte[] result = new byte[length];
		for (int i = 0; i < length; i++) {
			result[i] = (byte) (key1Bytes[i] ^ key2Bytes[i]);
		}

		return BASE64Encoder.encode(result) + "%1%.";
	}

}
